﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

#region Usings

using System;
using System.Reflection;
using System.Windows.Input;
using Microsoft.Practices.Unity;
using Microsoft.Win32;
using ScrumTable.Common.Collections;
using ScrumTable.Common.Logging;
using ScrumTable.Common.Security;
using ScrumTable.Common.SysLibs;
using ScrumTable.Config.ConfigManagement;
using ScrumTable.Config.UserManagement;
using ScrumTable.UI.ViewModel.Controller;

#endregion

namespace ScrumTable.UI.ViewModel.View
{
    /// <summary>
    /// Description of the class
    /// </summary>
    public class StartScreenViewModel : ViewModelBase
    {

        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------
        private string _error;
        private RelayCommand _activateCommand;
        private bool _isWebActivation;



        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------


        /// <summary>
        /// Gets or sets the error info.
        /// </summary>
        /// <value>The error info.</value>
        public string ErrorConnect
        {
            get
            {
                return _error;
            }
            set
            {
                _error = value;
                SendPropertyChanged("ErrorConnect");
            }
        }

        /// <summary>
        /// Gets or sets the login account list.
        /// </summary>
        /// <value>The login account list.</value>
        [Dependency]
        public LoginAccountManager LoginAccountList
        {
            get;
            set;
        }


        /// <summary>
        /// Gets or sets the config manager.
        /// </summary>
        /// <value>The login account manager.</value>
        [Dependency]
        public ConfigManager ConfigManager { get; set; }


        public bool OnboardKeyboardEnabled
        {
            get
            {
                return ConfigManager.OnboardKeyboardEnabled; 
            }
            set
            {
                ConfigManager.OnboardKeyboardEnabled = value;
                SendPropertyChanged("OnboardKeyboardEnabled");
            }
        }
        public string AssemblyInfo
        {
            get { return Assembly.GetExecutingAssembly().GetName().Version.ToString(); }
        }

        public string AssemblyDescription
        {
            get
            {
                var attributs = Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), false);
                if (attributs.Length > 0) 
                {
                    return ((AssemblyDescriptionAttribute)attributs[0]).Description;
                }
                
                return "";
            }
        }


        /// <summary>
        /// Command for Testing the connection
        /// </summary>
        /// <value>Command for connection testing</value>
        public ICommand ChangeKeyBoardSetting
        {
            get
            {
                return new RelayCommand(
                        param => OnboardKeyboardEnabled = !OnboardKeyboardEnabled,
                        param => true
                        );
            }
        }

        public bool IsFlickEnabled
        {
            
            get 
            { 
                var value = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Wisp\Pen\SysEventParameters", "FlickMode", "0");
                return value.ToString() == "1";
            }
        }

      


        #endregion

        #region Constructors / Destructor
        //--------------------------------------------------------------------
        // Constructors / Destructor
        //--------------------------------------------------------------------

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------
        /// <summary>
        /// Changes the current user.
        /// </summary>
        /// <param name="id">The id of the current user</param>
        public void ChangeCurrentUser(long id)
        {
            LoginAccountList.SetCurrentLoginAccount(id);
        }
      
        #endregion

        #region Events
        //--------------------------------------------------------------------
        // Events
        //--------------------------------------------------------------------

        #endregion

    }
}